<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta name="copyright" content=
"Copyright (c) IBM Corporation and others 2000, 2011. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<link rel="STYLESHEET" href="../book.css" charset="ISO-8859-1" type="text/css" />
<title>Opening a Java editor</title>
<link rel="stylesheet" type="text/css" href="../book.css" />
</head>
<body>
<h3>Opening a Java editor</h3>
<p>The following snippet shows how <b><a href=
"../reference/api/org/eclipse/jdt/ui/JavaUI.html">JavaUI</a></b> can be used to open a Java editor
and display a specific member of a Java compilation unit.</p>

<pre class="color1">
    void showMethod(IMember member) throws PartInitException, JavaModelException {
        ICompilationUnit cu = member.getCompilationUnit();
        IEditorPart javaEditor = JavaUI.openInEditor(cu);
        JavaUI.revealInEditor(javaEditor, (IJavaElement)member);
    }
</pre>
<p>The methods <code>openInEditor</code> and <code>revealInEditor</code> also work for class files
and for members contained in class files.</p>
</body>
</html>
